package com.yangye.pisystem.controller;

import com.yangye.picommon.model.PiResult;
import com.yangye.pisystem.domain.SysRouter;
import com.yangye.pisystem.service.SysRouterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author yangye
 * @date 2019/8/6
 */
@RestController
@RequestMapping("/sys/routers")
public class SysRouterController {

	@Autowired
	private SysRouterService sysRouterService;

	@PostMapping("/")
	PiResult add(SysRouter sysRouter) {
		return PiResult.succeed(sysRouterService.add(sysRouter));
	}

	@DeleteMapping("/{id}")
	PiResult remove(@PathVariable Long id) {
		sysRouterService.remove(id);
		return PiResult.succeed();
	}

	@PutMapping("/")
	PiResult update(SysRouter sysRouter) {
		sysRouterService.update(sysRouter);
		return PiResult.succeed();
	}

	@GetMapping("/{id}")
	PiResult get(@PathVariable Long id) {
		return PiResult.succeed(sysRouterService.get(id));
	}

	@GetMapping("/tree")
	PiResult listTree() {
		return PiResult.succeed(sysRouterService.listTree());
	}


}
